package com.android.questions.ui.adapter;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.android.questions.R;
import com.android.questions.entity.MeEntity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

/**
 * FileName: MeAdapter
 * Author: admin
 * Date: 2021/11/4 16:44
 * Description:
 */
public class MeAdapter extends BaseQuickAdapter<MeEntity, BaseViewHolder> {
    public MeAdapter() {
        super(R.layout.item_me);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, MeEntity meEntity) {

        TextView tvItem = baseViewHolder.getView(R.id.tv_item);
        TextView tvContent = baseViewHolder.getView(R.id.tv_content);
        View viewItem = baseViewHolder.getView(R.id.viewItem);
        final int position = getItemPosition(meEntity);

        if (position == getItemCount() - 1) {
            viewItem.setVisibility(View.GONE);
        }

        Drawable drawableLeft = ContextCompat.getDrawable(getContext(), meEntity.icon);
        tvItem.setCompoundDrawablesWithIntrinsicBounds(drawableLeft,
                null, null, null);
        tvItem.setCompoundDrawablePadding(24);
        tvItem.setText(meEntity.getName());
        tvContent.setVisibility(View.VISIBLE);
    }
}